19  CJS [t,t] - growth model

Simple CJS model integrated with a growth in weight model to get phi, p, and growth estimates to compare with Neural Network CMR/growth model

In all the models below, 1 = not observed and 2 = observed in the input encounter data.
Encounter data are available here in the eh.csv file. Weight data are in weight.csv

19.0.1 modelNum 1: g(i,t) model

Growth rate (gr) model structure:

gr(t,i) <- grInt(t,i)

Model code is in ./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_functionsToSource.R
Model is run ‘by hand’ in ./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_makeFile.R
Not using this: Targets are loaded in R/modelCMR_tt_growth_NN_OB.R and saved as modelCMR_tt_growth_NN_OB_target

Model runs:

19.0.1.1 Retrieve model results

Code
library(targets)
# Following https://oliviergimenez.github.io/bayesian-cr-workshop/worksheets/4_demo.html
# 
modelNum = 1 # growth only

#load('./models/cmrNN_OB/tt_growth/runsOut/tt_growth_NN_OB_mostRecent.RData')
load(paste0('./models/cmrNN_OB/tt_growth/runsOut/tt_growth_NN_OB_model', modelNum, '_mostRecent.RData'))
out_NN_OBmod1 <- d

#Input data
eh <- tar_read(eh_OB_2002_2014_target)

19.0.1.2 Model code

In the model code, a value of 1 for z or in gamma or omega signifies the individual is alive and a value of 2 signifies the individual is dead. y[i,j] is the observed data (encounter history file).

Code
out_NN_OBmod1$modelCode
{
    for (i in 1:N) {
        weight[i, first[i]] ~ dnorm(3.7, sd = 1.7)
        weightDATA[i, first[i]] ~ dnorm(weight[i, first[i]], 
            sd = 0.2)
        for (t in first[i]:(last[i] - 1)) {
            weight[i, t + 1] <- weight[i, t] + gr[i, t] * sampleIntervalDATA[i, 
                t]
            weightDATA[i, t + 1] ~ dnorm(weight[i, t + 1], sd = 0.2)
        }
    }
    for (i in 1:N) {
        for (t in first[i]:(last[i] - 1)) {
            gr[i, t] ~ dnorm(grIntT[t], sd = 0.33)
        }
    }
    for (t in 1:(T - 1)) {
        grIntT[t] ~ T(dnorm(0, sd = 1.5), -3.5, 3.5)
        grIntTOut[t] <- ilogit(grIntT[t])
    }
}

19.0.1.3 Model statistics

Run statistics
nIter nBurnin nChains thinRate
5000 2000 2 5

[1] “Run time = 26.607 mins”

19.0.1.4 Plot traces

Code
  priors <- runif(out_NN_OBmod1$runData$nIter * out_NN_OBmod1$runData$nChains, 0, 1)
  MCMCtrace(object = out_NN_OBmod1$mcmc,
            #ISB = FALSE,
            #exact = TRUE, 
            params = c("grIntTOut"),
            pdf = FALSE, 
            priors = priors)

19.0.1.5 Summary data

Code
  MCMCplot(object = out_NN_OBmod1$mcmc, params = c("grIntTOut"))

Summary values

Code
#|
  (summary_tt_growth <- MCMCsummary(object = out_NN_OBmod1$mcmc, params = c("grIntTOut"), round = 3) %>%
    rownames_to_column(var = "var"))
             var  mean    sd  2.5%   50% 97.5% Rhat n.eff
1   grIntTOut[1] 0.506 0.003 0.500 0.506 0.512 1.00   935
2   grIntTOut[2] 0.511 0.003 0.505 0.511 0.516 1.01   944
3   grIntTOut[3] 0.519 0.003 0.513 0.518 0.524 1.02  1152
4   grIntTOut[4] 0.507 0.003 0.501 0.507 0.513 1.00  1205
5   grIntTOut[5] 0.515 0.004 0.508 0.515 0.522 1.02   914
6   grIntTOut[6] 0.506 0.004 0.498 0.506 0.514 1.00   976
7   grIntTOut[7] 0.525 0.005 0.516 0.525 0.535 1.02   950
8   grIntTOut[8] 0.524 0.008 0.509 0.525 0.539 1.00   988
9   grIntTOut[9] 0.473 0.010 0.452 0.473 0.492 1.23  1064
10 grIntTOut[10] 0.493 0.013 0.469 0.493 0.520 1.00   978
11 grIntTOut[11] 0.681 0.015 0.651 0.682 0.709 1.29   815
Code
  # To get the mMCMCSummaryRMNA funcion which I adapted to deal with NAs
  source('./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_functionsToSource.R')
  
  summary_tt_growth_z0 <- MCMCSummaryRMNA(object = out_NN_OBmod1$mcmc, params = c("weight"), round = 3) %>%
    rownames_to_column(var = "var") |> 
    mutate(
      ind0 = str_match(var, "([0-9]+), ([0-9]+)")[,2],
      t0 =   str_match(var, "([0-9]+), ([0-9]+)")[,3],
      ind = as.numeric(ind0),
      t = as.numeric(t0)
    ) |> 
    dplyr::select(-c(t0, ind0))

Add other variables to summary values

Code
  ehLong <- 
    eh$eh |>
    as.data.frame() |> 
    rownames_to_column("ind0") |> 
    pivot_longer(starts_with("ais")) |> 
    mutate(
      t = as.numeric(str_match(name, "([0-9]+)")[,1]),
      enc = value,
      ind = as.numeric(ind0)
    ) |> 
    dplyr::select(-c(name, value, ind0))
  
  firstLong <- eh$first |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) |> 
    rename(first = value)
  
  lastLong <- eh$last |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) |> 
    rename(last = value)
    
  cohortLong <- eh$cohort |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) 
  
  weightLong <- 
    eh$weight |>
    as.data.frame() |> 
    rownames_to_column("ind0") |> 
    pivot_longer(starts_with("ais")) |> 
    mutate(
      t = as.numeric(str_match(name, "([0-9]+)")[,1]),
      weight = value,
      ind = as.numeric(ind0)
    ) |> 
    dplyr::select(-c(name, value, ind0))
  
  summary_tt_growth_z <- summary_tt_growth_z0 |> 
    left_join(ehLong) |> 
    mutate(
      # meanM1 = mean - 1,
      # pSurv = ifelse(meanM1 == 0, 1, 1 - meanM1),
      enc8 = ifelse(enc == 1, 0.8, 0)
    ) |> 
    left_join(firstLong) |> 
    left_join(lastLong) |> 
    left_join(cohortLong) |> 
    left_join(weightLong) |> 
    mutate(
      resid = weight - mean
    ) 
Code
  resids <- summary_tt_growth_z |> 
    group_by(ind) |> 
    summarize(
      meanResid = mean(abs(resid), na.rm = TRUE),
      n = n()
    ) |> 
    ungroup()

  summary_tt_growth_zR <- 
    summary_tt_growth_z |> 
    left_join(resids)
Code
ojs_define(numTags_OJS = dim(eh$tags)[1])
ojs_define(summary_tt_growth_zR_OJS = (summary_tt_growth_zR))

19.0.1.6 Plot predicted and observed masses for selected individuals

Select one or more individuals:

Code
viewof selectInd = Inputs.select([...Array(numTags_OJS).keys()], {
  label: "Which fish?",
  value: 1,
  step: 1,
  multiple: true
})

summary_tt_growth_zR_OJS_T = transpose(summary_tt_growth_zR_OJS)
summary_tt_growth_zR_OJS_T_selected = summary_tt_growth_zR_OJS_T.filter((d) =>
  selectInd.includes(d.ind)
)

Black dots/line is estimated mass and orange dots are observed masses. The green line is the first observation and the red line is the last observation. The number in the upper right corner of each panel is the fish’s cohort.

Code
Plot.plot({
  width: width,
  height: 350,
  inset: 10,
  color: {
    scheme: "greys"
  },
  x: { label: "Age/season combination" },
  y: { label: "Body mass (mg)" },
  marks: [
    Plot.frame(),
    Plot.dot(summary_tt_growth_zR_OJS_T_selected, {
      x: "t",
      y: "mean"
    }),
    Plot.line(summary_tt_growth_zR_OJS_T_selected, {
      x: "t",
      y: "mean"
    }),
    Plot.dot(summary_tt_growth_zR_OJS_T_selected, {
      x: "t",
      y: "weight",
      fill: "orange"
    }),
    Plot.ruleX(summary_tt_growth_zR_OJS_T_selected, {
      x: "first",
      y: 3,
      "stroke": "green"
    }),
    Plot.ruleX(summary_tt_growth_zR_OJS_T_selected, {
      x: "last",
      y: 3,
      "stroke": "red"
    }),
    Plot.text(summary_tt_growth_zR_OJS_T_selected, 
      Plot.selectFirst({
        x: 9,
        y: 4,
        text: d => "Cohort = " + d.cohort
      })
    ),
    Plot.text(summary_tt_growth_zR_OJS_T_selected, 
      Plot.selectFirst({
        x: 9,
        y: 8,
        text: d => "Residual = " + d.meanResid
      })
    )
  ],
  facet: {
    data: summary_tt_growth_zR_OJS_T_selected,
    x: "ind"
  }
})

19.0.2 modelNum 2: phi(i,t) + g(i,t), p(i,t) model

Model with phi and p for each age-in-samples (t = column in the encounter history file) and individual (i)

Probability of survival (phi) model structure:

phi(t,i) <- phiInt(t,i)

Probability of capture (p) model structure:

p(t,i) <- pInt(t,i)

Growth rate (gr) model structure:

gr(t,i) <- grInt(t,i)

Survival/growth rate interaction:

Additive

Model code is in ./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_functionsToSource.R
Model is run ‘by hand’ in ./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_makeFile.R
Not using this: Targets are loaded in R/modelCMR_tt_growth_NN_OB.R and saved as modelCMR_tt_growth_NN_OB_target

Model runs:

19.0.2.1 Retrieve model results

Code
library(targets)
# Following https://oliviergimenez.github.io/bayesian-cr-workshop/worksheets/4_demo.html
# 
modelNum = 2 # phi + growth

#load('./models/cmrNN_OB/tt_growth/runsOut/tt_growth_NN_OB_mostRecent.RData')
load(paste0('./models/cmrNN_OB/tt_growth/runsOut/tt_growth_NN_OB_model', modelNum, '_mostRecent.RData'))
out_NN_OBmod2 <- d

#Input data
eh <- tar_read(eh_OB_2002_2014_target)

19.0.2.2 Model code

In the model code, a value of 1 for z or in gamma or omega signifies the individual is alive and a value of 2 signifies the individual is dead. y[i,j] is the observed data (encounter history file).

Code
out_NN_OBmod2$modelCode
{
    for (i in 1:N) {
        weight[i, first[i]] ~ dnorm(3.7, sd = 1.7)
        weightDATA[i, first[i]] ~ dnorm(weight[i, first[i]], 
            sd = 0.2)
        for (t in first[i]:(last[i] - 1)) {
            weight[i, t + 1] <- weight[i, t] + gr[i, t] * sampleIntervalDATA[i, 
                t]
            weightDATA[i, t + 1] ~ dnorm(weight[i, t + 1], sd = 0.2)
        }
    }
    for (i in 1:N) {
        for (t in first[i]:(last[i] - 1)) {
            gr[i, t] ~ dnorm(grIntT[t], sd = 2)
        }
    }
    for (t in 1:(T - 1)) {
        grIntT[t] ~ T(dnorm(0, sd = 1.5), -3.5, 3.5)
    }
    delta[1] <- 1
    delta[2] <- 0
    for (i in 1:N) {
        for (t in first[i]:(last[i] - 1)) {
            gamma[1, 1, t, i] <- phi[i, t]
            gamma[1, 2, t, i] <- 1 - phi[i, t]
            gamma[2, 1, t, i] <- 0
            gamma[2, 2, t, i] <- 1
        }
    }
    for (t in 1:(T - 1)) {
        p[t] ~ dunif(0, 1)
        omega[1, 1, t] <- 1 - p[t]
        omega[1, 2, t] <- p[t]
        omega[2, 1, t] <- 1
        omega[2, 2, t] <- 0
    }
    for (i in 1:N) {
        for (t in first[i]:(last[i] - 1)) {
            logit(phi[i, t]) <- phiInt[i, t]
        }
    }
    for (i in 1:N) {
        for (t in first[i]:(last[i] - 1)) {
            phiInt[i, t] ~ dnorm(phiIntT[t], sd = 2)
        }
    }
    for (t in 1:(T - 1)) {
        phiIntT[t] ~ T(dnorm(0, sd = 1.5), -3.5, 3.5)
    }
    for (i in 1:N) {
        z[i, first[i]] ~ dcat(delta[1:2])
        for (j in first[i]:(last[i] - 1)) {
            z[i, j + 1] ~ dcat(gamma[z[i, j], 1:2, j, i])
            y[i, j + 1] ~ dcat(omega[z[i, j + 1], 1:2, j])
        }
    }
}

19.0.2.3 Model statistics

Run statistics
nIter nBurnin nChains thinRate
5000 2000 2 5

[1] “Run time = 1.602 hours”

19.0.2.4 Plot traces

Code
  priors <- runif(out_NN_OBmod2$runData$nIter * out_NN_OBmod2$runData$nChains, 0, 1)
  MCMCtrace(object = out_NN_OBmod2$mcmc,
            #ISB = FALSE,
            #exact = TRUE, 
            params = c("grIntTOut"),
            pdf = FALSE, 
            priors = priors)

19.0.2.5 Summary data

Code
  MCMCplot(object = out_NN_OBmod2$mcmc, params = c("phiIntTOut"))

Code
  MCMCplot(object = out_NN_OBmod2$mcmc, params = c("p"))

Code
  MCMCplot(object = out_NN_OBmod2$mcmc, params = c("grIntTOut"))

Summary values

Code
#|
  (summary_tt_growth_mod2 <- MCMCsummary(object = out_NN_OBmod2$mcmc, params = c("phiIntTOut", "p", "grIntTOut"), round = 3) %>%
    rownames_to_column(var = "var"))
              var  mean    sd  2.5%   50% 97.5% Rhat n.eff
1   phiIntTOut[1] 0.912 0.017 0.876 0.912 0.944 1.17    45
2   phiIntTOut[2] 0.910 0.019 0.868 0.913 0.941 1.05    29
3   phiIntTOut[3] 0.855 0.022 0.808 0.857 0.893 1.04    43
4   phiIntTOut[4] 0.734 0.031 0.670 0.736 0.790 1.50    47
5   phiIntTOut[5] 0.713 0.027 0.655 0.713 0.763 1.05    56
6   phiIntTOut[6] 0.798 0.035 0.727 0.799 0.858 1.25    29
7   phiIntTOut[7] 0.878 0.038 0.799 0.883 0.943 1.07    12
8   phiIntTOut[8] 0.268 0.048 0.183 0.268 0.364 1.09    29
9   phiIntTOut[9] 0.724 0.091 0.559 0.729 0.893 1.01     8
10 phiIntTOut[10] 0.663 0.127 0.355 0.665 0.873 1.23    10
11 phiIntTOut[11] 0.517 0.109 0.340 0.510 0.729 1.03     8
12           p[1] 0.598 0.021 0.556 0.598 0.638 1.04   123
13           p[2] 0.448 0.018 0.413 0.448 0.483 1.01   172
14           p[3] 0.707 0.019 0.669 0.707 0.743 1.03   208
15           p[4] 0.655 0.022 0.614 0.656 0.697 1.03   174
16           p[5] 0.634 0.024 0.585 0.635 0.680 1.00   267
17           p[6] 0.492 0.027 0.440 0.493 0.544 1.09   212
18           p[7] 0.730 0.035 0.659 0.731 0.795 1.00    92
19           p[8] 0.776 0.050 0.668 0.778 0.865 1.01   280
20           p[9] 0.620 0.067 0.483 0.623 0.741 1.09   122
21          p[10] 0.661 0.091 0.480 0.663 0.833 1.04   199
22          p[11] 0.864 0.094 0.662 0.879 0.995 1.01   214
23   grIntTOut[1] 0.499 0.003 0.493 0.499 0.505 1.05  1090
24   grIntTOut[2] 0.510 0.003 0.505 0.511 0.516 1.00  1118
25   grIntTOut[3] 0.514 0.003 0.509 0.513 0.519 1.01   938
26   grIntTOut[4] 0.508 0.003 0.502 0.508 0.514 1.00  1025
27   grIntTOut[5] 0.508 0.004 0.501 0.508 0.515 1.02   878
28   grIntTOut[6] 0.513 0.004 0.505 0.513 0.521 1.00  1156
29   grIntTOut[7] 0.529 0.005 0.520 0.529 0.538 1.02   854
30   grIntTOut[8] 0.496 0.008 0.480 0.496 0.511 1.01  1110
31   grIntTOut[9] 0.492 0.010 0.473 0.493 0.512 1.00   971
32  grIntTOut[10] 0.558 0.013 0.533 0.558 0.585 1.02   915
33  grIntTOut[11] 0.537 0.016 0.505 0.537 0.570 1.04   421
Code
  # To get the mMCMCSummaryRMNA funcion which I adapted to deal with NAs
  source('./models/cmrNN_OB/tt_growth/modelCMR_tt_growth_NN_OB_functionsToSource.R')
  
  summary_tt_growth_z0_mod2 <- MCMCSummaryRMNA(object = out_NN_OBmod2$mcmc, params = c("weight"), round = 3) %>%
    rownames_to_column(var = "var") |> 
    mutate(
      ind0 = str_match(var, "([0-9]+), ([0-9]+)")[,2],
      t0 =   str_match(var, "([0-9]+), ([0-9]+)")[,3],
      ind = as.numeric(ind0),
      t = as.numeric(t0)
    ) |> 
    dplyr::select(-c(t0, ind0))
  
  summary_tt_z0_mod2 <- MCMCSummaryRMNA(object = out_NN_OBmod2$mcmc, params = c("z"), round = 3) %>%
    rownames_to_column(var = "var") |> 
    mutate(
      ind0 = str_match(var, "([0-9]+), ([0-9]+)")[,2],
      t0 =   str_match(var, "([0-9]+), ([0-9]+)")[,3],
      ind = as.numeric(ind0),
      t = as.numeric(t0)
    ) |> 
    dplyr::select(-c(t0, ind0))

Add other variables to summary values

Code
  ehLong <- 
    eh$eh |>
    as.data.frame() |> 
    rownames_to_column("ind0") |> 
    pivot_longer(starts_with("ais")) |> 
    mutate(
      t = as.numeric(str_match(name, "([0-9]+)")[,1]),
      enc = value,
      ind = as.numeric(ind0)
    ) |> 
    dplyr::select(-c(name, value, ind0))
  
  firstLong <- eh$first |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) |> 
    rename(first = value)
  
  lastLong <- eh$last |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) |> 
    rename(last = value)
    
  cohortLong <- eh$cohort |> 
    as_tibble() |> 
    rownames_to_column("ind") |> 
    mutate(ind = as.numeric(ind)) 
  
  weightLong <- 
    eh$weight |>
    as.data.frame() |> 
    rownames_to_column("ind0") |> 
    pivot_longer(starts_with("ais")) |> 
    mutate(
      t = as.numeric(str_match(name, "([0-9]+)")[,1]),
      weight = value,
      ind = as.numeric(ind0)
    ) |> 
    dplyr::select(-c(name, value, ind0))
  
  summary_tt_growth_z_mod2 <- summary_tt_growth_z0_mod2 |> 
    left_join(ehLong) |> 
    mutate(
      # meanM1 = mean - 1,
      # pSurv = ifelse(meanM1 == 0, 1, 1 - meanM1),
      enc8 = ifelse(enc == 1, 0.8, 0)
    ) |> 
    left_join(firstLong) |> 
    left_join(lastLong) |> 
    left_join(cohortLong) |> 
    left_join(weightLong) |> 
    mutate(
      resid = weight - mean
    ) 
    
  summary_tt_z_mod2 <- summary_tt_z0_mod2 |> 
    left_join(ehLong) |> 
    mutate(
      # meanM1 = mean - 1,
      # pSurv = ifelse(meanM1 == 0, 1, 1 - meanM1),
      enc8 = ifelse(enc == 1, 0.8, 0)
    ) |> 
    left_join(firstLong) |> 
    left_join(lastLong) |> 
    left_join(cohortLong) 
Code
  resids_mod2 <- summary_tt_growth_z_mod2 |> 
    group_by(ind) |> 
    summarize(
      meanResid = mean(abs(resid), na.rm = TRUE),
      n = n()
    ) |> 
    ungroup()

  summary_tt_growth_zR_mod2 <- 
    summary_tt_growth_z |> 
    left_join(resids_mod2)
Code
ojs_define(numTags_OJS_mod2 = dim(eh$tags)[1])
ojs_define(summary_tt_growth_zR_OJS_mod2 = (summary_tt_growth_zR_mod2))
ojs_define(summary_tt_z_OJS_mod2 = (summary_tt_z_mod2))

19.0.2.6 Plot predicted and observed masses for selected individuals

Select one or more individuals:

Code
viewof selectInd_mod2 = Inputs.select([...Array(numTags_OJS).keys()], {
  label: "Which fish?",
  value: 1,
  step: 1,
  multiple: true
})

summary_tt_growth_zR_OJS_T_mod2 = transpose(summary_tt_growth_zR_OJS_mod2)
summary_tt_growth_zR_OJS_T_selected_mod2 = summary_tt_growth_zR_OJS_T_mod2.filter((d) =>
  selectInd_mod2.includes(d.ind)
)

summary_tt_z_OJS_T_mod2 = transpose(summary_tt_z_OJS_mod2)
summary_tt_z_OJS_T_selected_mod2 = summary_tt_z_OJS_T_mod2.filter((d) =>
  selectInd_mod2.includes(d.ind)
)

Black dots/line is estimated mass and orange dots are observed masses. The green line is the first observation and the red line is the last observation. The number in the upper right corner of each panel is the fish’s cohort.

Code
Plot.plot({
  width: width,
  height: 350,
  inset: 10,
  color: {
    scheme: "greys"
  },
  x: { label: "Age/season combination" },
  y: { label: "Body mass (mg)" },
  marks: [
    Plot.frame(),
    Plot.dot(summary_tt_growth_zR_OJS_T_selected_mod2, {
      x: "t",
      y: "mean"
    }),
    Plot.line(summary_tt_growth_zR_OJS_T_selected_mod2, {
      x: "t",
      y: "mean"
    }),
    Plot.dot(summary_tt_growth_zR_OJS_T_selected_mod2, {
      x: "t",
      y: "weight",
      fill: "orange"
    }),
    Plot.ruleX(summary_tt_growth_zR_OJS_T_selected_mod2, {
      x: "first",
      y: 3,
      "stroke": "green"
    }),
    Plot.ruleX(summary_tt_growth_zR_OJS_T_selected_mod2, {
      x: "last",
      y: 3,
      "stroke": "red"
    }),
    Plot.text(summary_tt_growth_zR_OJS_T_selected_mod2, 
      Plot.selectFirst({
        x: 9,
        y: 4,
        text: d => "Cohort = " + d.cohort
      })
    ),
    Plot.text(summary_tt_growth_zR_OJS_T_selected_mod2, 
      Plot.selectFirst({
        x: 9,
        y: 8,
        text: d => "Residual = " + d.meanResid
      })
    )
  ],
  facet: {
    data: summary_tt_growth_zR_OJS_T_selected_mod2,
    x: "ind"
  }
})

19.0.2.7 Plot survival

Black dots/line is estimated probability of survival and orange dots are encountered yes (y = 0.8)/no (y = 0). The green line is the first observation and the red line is the last observation. The number in the upper right corner of each panel is the fish’s cohort.

Code
Plot.plot({
  width: width,
  height: 350,
  inset: 10,
  color: {
    scheme: "greys"
  },
  x: { label: "Age/season combination" },
  y: { label: "Probability of survival" },
  marks: [
    Plot.frame(),
    Plot.dot(summary_tt_z_OJS_T_selected_mod2, {
      x: "t",
      y: "pSurv"
    }),
    Plot.dot(summary_tt_z_OJS_T_selected_mod2, {
      x: "t",
      y: "enc8",
      fill: "orange"
    }),
    Plot.line(summary_tt_z_OJS_T_selected_mod2, {
      x: "t",
      y: "pSurv"
    }),
    Plot.ruleX(summary_tt_z_OJS_T_selected_mod2, {
      x: "first",
      y: 1,
      "stroke": "green"
    }),
    Plot.ruleX(summary_tt_z_OJS_T_selected_mod2, {
      x: "last",
      y: 1,
      "stroke": "red"
    })
    ,
    Plot.text(summary_tt_z_OJS_T_selected_mod2, 
      Plot.selectFirst({
        x: 11,
        y: 1,
        text: d => d.cohort
      })
    )
  ],
  facet: {
    data: summary_tt_z_OJS_T_selected_mod2,
    x: "ind"
  }
})

19.0.2.8 Output model summary data for Xiaowei

Code
  #write.csv(summary_tt, './models/cmrNN_OB/tt/dataOut/xiaowei/summary_tt.csv')
  
  #write.csv(summary_tt_z, './models/cmrNN_OB/tt/dataOut/xiaowei/summary_tt_z.csv')